<?php

require_once('db/db.php');

$db=new DB;

$page=1;
$rows=10;
if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
if(isset($_REQUEST['rows'])){
	$rows=$_REQUEST['rows'];
}

$start=($page-1)*$rows;

$total_r=$db->get_one("select count(*) from product");
$total=current($total_r);
$result=$db->get_all("select id,name,category from product limit $start,$rows");
echo json_encode(array('total'=>$total, 'rows'=>$result));

?>
